<template>
  <view class="footer_wapper">
    <view class="fw_item" v-if="type === 0">
<!--      <image @click="onScan" src="http://121.41.75.32:8002/file/static/images/scan.png" class="fw_scan" />-->
      <view class="carBtn flex flex-row j-content a-item btn-font"  @click="onScan" >扫码</view>
      <view class="carBtn flex flex-row j-content a-item btn-font" @click="save" v-if="current === 0" >保存</view>
    </view>

    <view class="fw_item" v-if="type === 1">
      <image @click="onScan" src="http://121.41.75.32:8002/file/static/images/scan.png" class="fw_scan" />
      <button @click="onLoading" type="primary" class="fw_btn" size="mini">装车</button>
    </view>

    <view class="fw_item" v-if="type === 2">
<!--      <image @click="onScan" src="http://121.41.75.32:8002/file/static/images/scan.png" class="fw_scan" />-->
      <button type="primary" class="sm"  @click="onScan" >扫码</button>
<!--      <button @click="onMap" type="primary" class="fw_btn1" size="mini">导航</button>-->
    </view>
  </view>
</template>

<script>
export default {
  props: {
    type: {
      default: 0,
    },
    location: {
      type: [String, null, undefined],
      default: ',',
    },
    current:{
      type:Number,
      default:0
    },
    scale: {
      type: [Number, null, undefined],
      default: 18,
    }, // 缩放比例，范围5~18
    name: {}, // 位置名
    address: {}, // 地址的详细说明
  },
  data() {
    return {}
  },
  watch:{
    current(n){
      console.log(n)
    }
  },
  methods: {
    onScan() {
      let th = this
      uni.scanCode({
        success: function (res) {
          th.$emit('scan', res.result)
        },
      })
    },
    onLoading() {},
    save(){
      this.$emit('save','1')
    },
    onMap() {
      if (this.location) {
        const { location, name, address } = this
        const [longitude, latitude] = location.split(',')
        uni.openLocation({ longitude, latitude, name, address })
      } else {
        this.$emit('map')
      }
    },
  },
}
</script>

<style scoped lang="scss">
.footer_wapper {
  background-color: #fff;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 98rpx;
  padding: 0 24rpx;
  ::after {
    content: ' ';
    position: absolute;
    top: 0;
    left: -50%;
    right: -50%;
    border-top: 1rpx solid #f2f2f2;
  }

  .fw_scan {
    width: 300rpx;
    height: 60rpx;
  }

  .fw_item {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
  }

  .fw_btn {
    position: absolute;
    right: 0;
    width: 596rpx;
    height: 72rpx;
    line-height: 72rpx;
    border-radius: 48rpx;
    background: #ee5c2b;
  }
  .carBtn{
    width: 680rpx;
    height: 100%;
    background-color: #ee5c2b;
    border-radius: 60rpx;
  }
  .fw_btn1 {
    position: absolute;
    right: 0;
    width: 161rpx;
    height: 72rpx;
    line-height: 72rpx;
    border-radius: 48rpx;
    background: #ee5c2b;
  }
}
.sm{
  background-color: #ee5c2b;
  width: 90%;
  height: 90rpx;
  border-radius: 100rpx;
}
</style>
